package com.tw101.module1;

import java.util.ArrayList;
import java.util.List;

public class Prime {
    public static List<Integer> generate(int number) {
        int n = number;
        List<Integer> factors = new ArrayList<Integer>();

        for(int i = 2; i <= n; i++) {
            // Checks if the number divides equally
            while(n % i == 0 ) {
                // Adds the factor and uses the divided number for the next loop
                factors.add(i);
                n/= i;
            }
        }
        return factors;
    }
}
